﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "ProceduralMeshComponent.h"
#include "GameFramework/Actor.h"
#include "gameLiftActor.generated.h"

class FLiftWorld;

/**mesh需要的所有数据*/
struct FPricedMeshData
{
	TArray<int> Triangles;
	TArray<FVector> Vertices;
	TArray<FVector> Normals;
	TArray<FVector2D> UV0;
	TArray<FColor> VertexColors;
	TArray<FProcMeshTangent> MeshTangent;

	
	void Clear();

	bool IsValid()const;
};

class UStaticMesh;

/**
 * 
 */
UCLASS()
class GAMEOFLIFE_API AGameLiftActor : public AActor
{

	GENERATED_BODY()
private:

	FLiftWorld* liftWorld;

	
	float boxSizeHaf = 2;
	float boxSize = 10;



private:

	bool needTick;

	UPROPERTY(Category = Mesh, VisibleAnywhere)
	UProceduralMeshComponent* proceduralMeshComponent;

	FPricedMeshData referMeshData;

	FPricedMeshData ShowMeshData;


	bool CopyMeshData(UStaticMesh* mesh);


	void AddOneNodeToMesh(const FPricedMeshData& node, FVector point, float size);

public:

	AGameLiftActor();

	~AGameLiftActor();





	UFUNCTION(BlueprintCallable, Category = "AOneLife")
		void InitWorld(int x,int y,int z);


	UFUNCTION(BlueprintCallable, Category = "AOneLife")
		void InitStage(UStaticMesh* mesh);

	UFUNCTION(BlueprintCallable, Category = "AOneLife")
		void InitLift(TArray<int> lift);


	UFUNCTION(BlueprintCallable, Category = "AOneLife")
		int UpDataLift();


	UFUNCTION(BlueprintCallable, Category = "AOneLife")
		int ChangeTickTyp();


	UFUNCTION(BlueprintCallable, Category = "AOneLife")
		void SetKeepKey(int minKeep, int maxKeep, int maxNear);

	UFUNCTION(BlueprintCallable, Category = "AOneLife")
		void GetKeepKey(int& minKeep, int& maxKeep, int& maxNear);



	virtual void Tick(float DeltaSeconds);
	
};
